<template>
    <div class="login-page">
    <div class="login-content">
      <div class="top">
          <img src="https://msmk2019.oss-cn-shanghai.aliyuncs.com/uploads/image/2019EMSgrHV5vZ1566894495.png" alt="">
        <!-- <img :src="config.web_logo?config.web_logo:'@/assets/logo.png'" style="width:80%;margin:100px auto" class="logo" />
        <h4>{{config.web_title}}</h4> -->
      </div>
      <div :class="active!= 1 ? 'int_num':'int_num int_num_active'">
        <input
          type="number"
          placeholder="请输入手机号"
          maxlength="11"
          v-model="passwordData.mobile"
          @focus="active=1"
          @blur="active=''"
        />
      </div>
      <div :class="active!= 2 ? 'int_num':'int_num int_num_active'">
        <input
          type="password"
          placeholder="请输入密码"
          v-model="passwordData.user_pass"
          @focus="active=2"
          @blur="active=''"
        />
      </div>
      <div class="others">
        <span class="forget" @click="forgot">找回密码</span>
        <span class="login_CAPTCHA" @click="codeLogin">注册/验证码登录</span>
      </div>
    </div>
    <div class="login">
      <span @click="goLogin">登录</span>
    </div>
    <!-- <div class="otherLogin" v-if="showOther">
      <p>第三方登录</p>
      <div class="txLogin">
        <div class="wxLogin" @click="qqLogin(1)">
          <img src="@/assets/images/wechat.png" />
          <span>微信登录</span>
        </div>
        <div class="qqLogin" @click="qqLogin(2)">
          <img src="@/assets/images/QQ.png" alt />
          <span>QQ登录</span>
        </div>
      </div>
    </div> -->
  </div>
</template>

<script>
import {Login} from "../../request/api.js"
export default {
 data() {
    return {
      passwordData: {
        mobile: "",
        user_pass: ""
      },
      List:{},
      active: "",
      showOther: false
    };
  },
   methods: {
    goLogin() {
      let res =/^(?:(?:\+|00)86)?1[3-9]\d{9}$/
      if (!res.test(this.passwordData.mobile)) {
        this.$toast("手机号码格式不正确");
        return;
      }
        var obj= {
          mobile: this.passwordData.mobile,
          password: this.passwordData.user_pass,
          type: 1
        }
        Login(obj).then(res => {
          console.log(res.data)
          localStorage.setItem("adminToken", res.data.remember_token);
          localStorage.setItem("user_id", res.data.id);
          localStorage.setItem("List", JSON.stringify(res.data));
            this.$router.push({
              name: "my"
            });
        });
    },
    codeLogin() {
      this.$router.push({
        name: "SmsLogin"
      });
    },
    forgot() {
      this.$router.push({
        name: "ForgetPass"
      });
    },
    
  },
  mounted() {
    localStorage.removeItem("adminToken");
    localStorage.removeItem("user_id");
  }
}
</script>

<style scoped lang="scss">

.login-page {
  overflow: hidden;
}
.login-content {
  padding: 0 20px;
}
.top {
  img{
    width: 70%;
    display: block;
    margin: 50px auto;
  }
  .logo {
    display: block;
    width: 162px;
    margin-top: 80px;
  }
  h4 {
    font-size: 48px;
    font-family: PingFangSC-Semibold;
    font-weight: 600;
    color: rgba(89, 89, 89, 1);
    margin-top: 160px;
  }
}
input::-webkit-input-placeholder {
  /* placeholder颜色  */
  color: rgba(190, 190, 190, 1);
}
.int_num {
  height: 60px;
  background-color: #fff;
  border-bottom: 1px solid #f1f1f1;
  input {
    box-sizing: border-box;
    padding: 30px 0;
    border: 0;
    width: 540px;
    height: 100%;
    font-size: 18px;
    font-family: PingFangSC-Regular;
    font-weight: 400;
    line-height: 40px;
    float: left;
    outline: none;
  }
}
.int_num_active {
  border-color:#eb6100;
}
.login {
  width: 80%;
  height: 40px;
  margin: 30px auto ;
  // height: 374px;
  background: url("../../assets/theme-img/login-btn.png");
  background-size: 100% 100%;
  font-size: 20px;
  font-family: PingFangSC-Medium;
  font-weight: 500;
  text-align: center;
  color: rgba(255, 255, 255, 1);
  letter-spacing: 4px;
  span {
    display: inline-block;
    width: 100%;
    height: 40px;
    line-height: 40px;
  }
}
.others {
  width: 100%;
  margin-top: 30px;
  display: flex;
  justify-content: space-between;
  .forget {
    font-size: 18px;
    font-family: PingFangSC-Regular;
    font-weight: 400;
    color: rgba(153, 153, 153, 1);
  }
  .login_CAPTCHA {
    font-size: 18px;
    font-family: PingFangSC-Regular;
    font-weight: 400;
    color: rgba(153, 153, 153, 1);
  }
}

</style>
